//
//  SKProxy.m
//  ShiKe
//
//  Created by wwww on 2018/9/27.
//  Copyright © 2018年 LN. All rights reserved.
//

#import "SKProxy.h"

@implementation SKProxy

+(instancetype)initWithTarget:(id)target{
    
    SKProxy *proxy = [SKProxy alloc];
    proxy.target = target;
    
    return proxy;
}

- (nullable NSMethodSignature *)methodSignatureForSelector:(SEL)sel{
    
    NSLog(@"检验本类中该函数的签名");
    NSMethodSignature *sig;
    if ([self.target methodSignatureForSelector:sel])
    {
        //如果这里不把方法签名传到star上也会报错的，test方法找不到实现的目标
        sig = [self.target methodSignatureForSelector:sel];
    }
    return sig;
    
   // return [self.target methodSignatureForSelector:sel];
}

-(void)forwardInvocation:(NSInvocation *)invocation{
    
    SEL sel = [invocation selector];
    if([self.target respondsToSelector:sel]){
        [invocation invokeWithTarget:self.target];
    }
}


- (BOOL)respondsToSelector:(SEL)aSelector {
    return [self.target respondsToSelector:aSelector];
}

@end
